/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.maistre.swarn;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Louis Maistre
 */
public class Ressource {
	
    String name;
    long quantity; // > 0 via seter
 

    public Ressource(String name, long quantity) {
        this.name = name;
        this.setQuantity(quantity);
       
    }
    public Ressource(RessourceNames name, int quantity) {
    	this.name =name.toString();
    	this.setQuantity(quantity);
	}
	@Override
    public String toString() {
        return name + "{" + quantity+"}";
    }
    
    public void setQuantity(long quantity) {
    	if(quantity < 0){
    		this.quantity = 0;
    	}else{
    		this.quantity = quantity;	
    	}
	}
    
    public long getQuantity() {
    	if(this.quantity > 0)
    		return quantity;
    	else
    		return 0;
	}
    
  
    
 
	@Override
	public boolean equals(Object obj) {
	    Ressource  r = (Ressource)obj;
	    return name.equalsIgnoreCase(r.name);
	}
    
    
}
